//
//  MemberChangePhoneController.m
//  yameishe3
//
//  Created by pro on 2017/3/2.
//  Copyright © 2017年 yameishe. All rights reserved.
//

#import "MemberChangePhoneController.h"
#import "YMSMemberManager.h"
#import "QuestionView.h"
@interface MemberChangePhoneController ()<UIScrollViewDelegate>
{
   __weak IBOutlet UIScrollView *_scrollView;
    QuestionView *_questionView;
    NSMutableArray *_questionArray;
}

@end

@implementation MemberChangePhoneController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self controllerSetting];
    
    [self requestMyQuestion];
    _questionArray = [[NSMutableArray alloc]init];
    _questionView = [[[NSBundle mainBundle]loadNibNamed:@"QuestionView" owner:self options:nil] objectAtIndex:1];
    [_scrollView addSubview:_questionView];
    [_questionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_scrollView);
        make.leading.trailing.equalTo(self.view);
        make.height.equalTo(@([QuestionView viewHeight]));
    }];
    [_questionView setCallbackDidSubmit:^(NSDictionary *dic) {
        
    }];
    _scrollView.contentSize = CGSizeMake(0, _questionView.height);
   
}
-(void)requestMyQuestion
{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setValue:[YMSMember loginMember].token forKey:@"_token"];
    [[YMSMemberManager sharedInstance] MemberGetMyQuestionWithDic:dic successBlock:^(NSArray *result) {
        _questionArray = [NSMutableArray arrayWithArray:result];
        _questionView.questionArray = _questionArray;
    } failureBlock:^(NSString *error) {
     
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)setViewData
{

}

-(IBAction)onTouchChangePhoneFunction:(id)sender
{

    if ([self checkFunctionState]==NO) {
        return;
    }

}
-(BOOL)checkFunctionState
{
    return YES;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
 
*/
#pragma mark UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    for (UIView *view in _questionView.subviews) {
        for (UIView * subView in view.subviews) {
            [subView resignFirstResponder];
        }
        [view resignFirstResponder];
    }
}

@end
